N = 10000
ans = 0
target = '123456789'
d = {}
for i in xrange(1, N):
    for j in xrange(i + 1, N):
        if len(str(i)) + len(str(j)) + len(str(i * j)) > 9:
            break
        n = i * j
        sn = ''.join(list(str(n)))
        si = ''.join(list(str(i)))
        sj = ''.join(list(str(j)))
        s = list(sn + si + sj)
        s.sort()
        s = ''.join(s)
        if s == target:
            d[n] = 1

for nn in d:
    ans += nn

print ans
